package com.zr.java8.pattern.chain;

import com.zr.java8.pattern.chain.handler.GeneralManagerHandler;
import com.zr.java8.pattern.chain.handler.ManagerHandler;
import com.zr.java8.pattern.chain.handler.TeamLeadHandler;

public class LeaveApplication {
    private int days;

    public LeaveApplication(int days) {
        this.days = days;
    }

    public int getDays() {
        return days;
    }

    public static void main(String[] args) {
        // 创建责任链
        Approver teamLead = new TeamLeadHandler();
        Approver manager = new ManagerHandler();
        Approver generalManager = new GeneralManagerHandler();

        teamLead.setSuccessor(manager);
        manager.setSuccessor(generalManager);

        // 提交请假申请
        LeaveApplication application1 = new LeaveApplication(1);
        teamLead.processLeaveApplication(application1);

        LeaveApplication application5 = new LeaveApplication(5);
        teamLead.processLeaveApplication(application5);

        LeaveApplication application10 = new LeaveApplication(10);
        teamLead.processLeaveApplication(application10);

        LeaveApplication application15 = new LeaveApplication(15);
        teamLead.processLeaveApplication(application15);
    }
}
